﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

namespace CPPProject.Migrations
{
    public partial class updatecontract : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "CPPContract",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    TenantId = table.Column<int>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    LastModifierUserId = table.Column<long>(nullable: true),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    CompanyId = table.Column<long>(nullable: false),
                    ContractNum = table.Column<string>(maxLength: 50, nullable: false),
                    BizType = table.Column<string>(maxLength: 2, nullable: false),
                    CustomerId = table.Column<long>(nullable: false),
                    Address = table.Column<string>(maxLength: 500, nullable: true),
                    PaymentMtd = table.Column<string>(maxLength: 50, nullable: false),
                    PaymentPeriod = table.Column<string>(maxLength: 50, nullable: true),
                    Remark = table.Column<string>(maxLength: 500, nullable: true),
                    StartDate = table.Column<DateTime>(nullable: false),
                    EndDate = table.Column<DateTime>(nullable: false),
                    ReconciliationDate = table.Column<DateTime>(nullable: false),
                    Status = table.Column<string>(maxLength: 10, nullable: true),
                    ProjectName = table.Column<string>(maxLength: 500, nullable: true),
                    Days = table.Column<int>(nullable: false),
                    WarningDays = table.Column<int>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_CPPContract", x => x.Id);
                    table.ForeignKey(
                        name: "FK_CPPContract_CPPCompany_CompanyId",
                        column: x => x.CompanyId,
                        principalTable: "CPPCompany",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_CPPContract_CompanyId",
                table: "CPPContract",
                column: "CompanyId");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            //migrationBuilder.DropTable(
            //    name: "CPPContract");
        }
    }
}
